home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / misc / aprof334.lha / AProf334 / rexx / maxoncpp.aprof < prev   
Encoding:
Text File  |  1994-08-03  |  3.7 KB  |  190 lines

  1. /* Aprof unmangler for Maxon C++
  2.  *
  3.  * Not very beautiful!
  4.  *
  5.  * V3.30
  6.  */
  7.  
  8.  
  9. /* Data table */
  10.  
  11. maxon.1.key = "c"
  12. maxon.1.typ = "char"
  13. maxon.1.flg = "std"
  14.  
  15. maxon.2.key = "s"
  16. maxon.2.typ = "short"
  17. maxon.2.flg = "std"
  18.  
  19. maxon.3.key = "i"
  20. maxon.3.typ = "int"
  21. maxon.3.flg = "std"
  22.  
  23. maxon.4.key = "j"
  24. maxon.4.typ = "long"
  25. maxon.4.flg = "std"
  26.  
  27. maxon.5.key = "l"
  28. maxon.5.typ = "long long"
  29. maxon.5.flg = "std"
  30.  
  31. maxon.6.key = "f"
  32. maxon.6.typ = "float"
  33. maxon.6.flg = "std"
  34.  
  35. maxon.7.key = "d"
  36. maxon.7.typ = "double"
  37. maxon.7.flg = "std"
  38.  
  39. maxon.8.key = "D"
  40. maxon.8.typ = "long double"
  41. maxon.8.flg = "std"
  42.  
  43. maxon.9.key = "v"
  44. maxon.9.typ = "void"
  45. maxon.9.flg = "std"
  46.  
  47. maxon.10.key = "S"
  48. maxon.10.typ = "signed"
  49. maxon.10.flg = "std"
  50.  
  51. maxon.11.key = "U"
  52. maxon.11.typ = "unsigned"
  53. maxon.11.flg = "std"
  54.  
  55. maxon.12.key = "P"
  56. maxon.12.typ = "*"
  57. maxon.12.flg = "poi"
  58.  
  59. maxon.13.key = "R"
  60. maxon.13.typ = "&"
  61. maxon.13.flg = "ref"
  62.  
  63. maxon.14.key = "C"
  64. maxon.14.typ = "const"
  65. maxon.14.flg = "att"
  66.  
  67. maxon.15.key = "V"
  68. maxon.15.typ = "volatile"
  69. maxon.15.flg = "att"
  70.  
  71. maxon.16.key = "A"
  72. maxon.16.typ = "[]"
  73. maxon.16.flg = "array"
  74.  
  75. maxon.17.key = "F"
  76. maxon.17.typ = "(*)"
  77. maxon.17.flg = "func"
  78.  
  79. maxon.18.key = "E"7
  80. maxon.18.typ = "enum"
  81. maxon.18.flg = "enum"
  82.  
  83. maxon.0.key = "numeric"
  84. maxon.0.typ = "struct"
  85. maxon.0.flg = "struct"
  86.  
  87.  
  88. /* Get unmangled symbol */
  89. parse arg sym
  90.  
  91. cut = pos( "__", sym );
  92.  
  93. /* if cut = 0 => no c++ symbol, remove _ */
  94. if cut = 0 then do
  95.    if "_" = left( sym, 1 ) then
  96.       sym = right( sym, length( sym ) -1 );
  97.    exit sym
  98. end
  99.  
  100. /* sym is c++ sym */
  101. symname = left( sym, cut-1 );
  102. symargs = right( sym, length( sym ) - cut -1 ); /* mangled arg list */
  103.  
  104. poi = 0
  105. ref = 0
  106. ctype = ""   /* current type */
  107. arglist = "" /* deststring: char *, int, ... */
  108. att = 0      /* attribute (volatile, const) */
  109.  
  110. do while length( symargs ) > 0
  111.    /* get token */
  112.    if "NUM" = datatype( left( symargs, 2 ) ) then
  113.       token = 0
  114.    else do token = 1 to 18
  115.       if maxon.token.key = left( symargs, length( maxon.token.key ) ) then
  116.       break
  117.    end
  118.  
  119.    /* bad token */
  120.    if token = 19 then
  121.       exit sym
  122.  
  123.    select
  124.       /* structures, classes, unions */
  125.       when maxon.token.flg = "struct" then do
  126.          /* get length (2 digits) */
  127.          len = left( symargs, 2 )
  128.          /* remove length */
  129.          symargs = right( symargs, length( symargs ) -2 )
  130.          /* struct type */
  131.          ctype = "struct" left( symargs, len )
  132.          /* remove type */
  133.          symargs = right( symargs, length( symargs ) - len )
  134.          /* concat pointers */
  135.          if poi > 0 then do
  136.             ctype = ctype copies( "*", poi )
  137.             poi = 0
  138.          end
  139.          
  140.          arglist = arglist || "," ctype
  141.          
  142.          ctype = ""
  143.       end
  144.  
  145.       when maxon.token.flg = "std" then do
  146.          symargs = right( symargs, length( symargs ) -1 )
  147.          
  148.          ctype = maxon.token.typ
  149.          if poi > 0 then do
  150.             if att ~= 0 then 
  151.                ctype = att ctype copies( "*", poi )
  152.             else
  153.                ctype = ctype copies( "*", poi )
  154.  
  155.             poi = 0
  156.             att = 0
  157.          end
  158.          
  159.          arglist = arglist || "," ctype
  160.          
  161.          ctype = ""
  162.       end
  163.       
  164.       when maxon.token.flg = "poi" then do
  165.          symargs = right( symargs, length( symargs ) -1 )
  166.          poi = poi +1
  167.       end
  168.       
  169.       when maxon.token.flg = "ref" then do
  170.          symargs = right( symargs, length( symargs ) -1 )
  171.          ref = ref +1
  172.       end
  173.       
  174.       when maxon.token.flg = "att" then do
  175.          symargs = right( symargs, length( symargs ) -1 )
  176.          att = maxon.token.typ
  177.       end
  178.  
  179.       otherwise
  180.          break
  181.    end
  182. end
  183.  
  184. arglist = strip( arglist, "B", "," )
  185.  
  186. /* concat symbolname and arglist for return */
  187. exit symname || "(" || arglist ")"
  188.  
  189.  
  190.